<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<%@include file="/common/taglibs.jsp"%>
<%@include file="/common/meta.jsp"%>
<title>修改密码</title>
</head>
<body>
	<%@include file="/common/header.jsp"%>
	
	<form id="pwdForm" action="<c:url value='/pf/user/mPwd'/>" method="post" autocomplete="off">
		<input type="hidden" name="id" value="${user.id }"/>
		
		<table class="add_form" align="center">
			<tr>
				<td align="right" width="30%">
					<label>旧密码:</label>
				</td>
				<td width="70%">
					<input id="oldPwd" name="oldPwd" type="password" class="add_input" required/>
				</td>
			</tr>
			<tr>
				<td align="right">
					<label>新密码:</label>
				</td>
				<td>
					<input id="newPwd" name="newPwd" type="password" class="add_input" required/>
				</td>
			</tr>
			<tr>
				<td align="right">
					<label>确认密码:</label>
				</td>
				<td>
					<input id="cfmPwd" name="cfmPwd" type="password" class="add_input" required/>
				</td>
			</tr>
			<tr>
				<td colspan="2" align="center">
					<input id="submit" type="button" value="保存"/>
				</td>
			</tr>
		</table>
	</form>
	
	<%@include file="/common/footer.jsp"%>
	
	<script type="text/javascript">
		$(function() {
			var ajax_option = {
				success:function(data, status, xhr) {
					if("success" == status) {
						art.dialog.alert(data.msg);
					} else {
						art.dialog.alert(data.msg);
					}
				}
			};
			$("#pwdForm").ajaxForm();
			$("#submit").click(function() {
				if($("#pwdForm").valid()) {
					$("#pwdForm").ajaxSubmit(ajax_option);
				}
			});
			
			$("#pwdForm").validate({
				rules: {
					oldPwd: "required",
					newPwd: {
						required: true,
						minlength: 5
					},
					cfmPwd: {
						required: true,
						minlength: 5,
						equalTo: "#newPwd"
					}
				},
				messages: {
					oldPwd: "请输入旧密码",
					newPwd: {
						required: "请输入新密码",
						minlength: "密码长度不小于5"
					},
					cfmPwd: {
						required: "请输入确认密码",
						minlength: "密码长度不小于5",
						equalTo: "密码不一致"
					}
				}
			});
		});
	</script>
</body>
</html>